<template>
<onekit-page>
<onekit-view onekit-class="container">
	<div is="onekit-template-head" :DATA="`${JSON.stringify({title:'downloadFile'})}`"></div>
	<onekit-view onekit-class="page-body">
		<onekit-image v-if="imageSrc" :src="imageSrc" mode="center"></onekit-image>
		<template v-else>
			<onekit-view onekit-class="page-body-wording">
				<onekit-text onekit-class="page-body-text">点击按钮下载服务端示例图片</onekit-text>
			</onekit-view>
			<onekit-view onekit-class="btn-area">
				<onekit-button type="primary" @Tap="downloadImage">下载</onekit-button>
			</onekit-view>
		</template>
	</onekit-view>
	<div is="onekit-template-foot"></div>
</onekit-view>
</onekit-page></template>
<script>
/* eslint-disable */
import Vue from 'vue';
import onekit_template_0 from '../../../common/head.head.vue';Vue.component('onekit-template-head',onekit_template_0);
import onekit_template_1 from '../../../common/foot.foot.vue';Vue.component('onekit-template-foot',onekit_template_1);
const ONEKIT_JSON= {
  "navigationBarTitleText": "下载文件",
  "usingComponents": {
    
  }
};
const ONEKIT_SJS = {
};
import wx from '../../../../weixin2vue/wx.js';
import Macro from '../../../../weixin2vue/Macro.js';
const {getApp,getCurrentPages} = Macro;
import Page from '../../../../weixin2vue/OnekitPage.js';
import Component from '../../../../weixin2vue/OnekitComponent.js';
const demoImageFileId = require('../../../config').demoImageFileId;
export default Page(ONEKIT_JSON,["imageSrc"],ONEKIT_SJS,{
    "onShareAppMessage"(){
      return {
        "title":'下载文件',
        "path":'packageAPI/pages/download-file/download-file'
};
    },
    "downloadImage"(){
      const self = this;
      wx.cloud.downloadFile({
        "fileID":demoImageFileId,
        "success":(res)=>{
          console.log('downloadFile success, res is',res);
          self.setData({
              "imageSrc":res.tempFilePath
});
        },
        "fail":console.error
});
    }
});

</script>
<style 
 lang="css">
.page-body .onekit-image {
  width: 300px ;
  height: 300px ;
  margin: 0 38px ;
}
</style>